import axios from 'axios'

window.Promise = Promise // 防止部分库内部使用Promise没被profill

const http = axios.create({
  headers: {
    'Cache-Control': 'no-cache',
    'Content-Type': 'application/x-www-form-urlencoded',
    'X-Requested-With': 'XMLHttpRequest'
  }
})
http.interceptors.request.use(function(config) {
  if (config.params) {
    config.params._time = +new Date()
  } else {
    config.params = {
      _time: +new Date()
    }
  }
  return config
})
export default http
